Page({
    data: {
        dataArr: [],
        sum: 1,
        buttons: [ {
            label: "关于照片墙",
            icon: "/images/about.png"
        }, {
            label: "分享照片",
            icon: "/images/sharePhoto.png"
        } ]
    },
    onLoad: function(a) {
        this.getDBData(1);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.getDBData(1);
    },
    onReachBottom: function() {
        var a = this.data.sum;
        this.data.dataArr.length < 10 ? a = 1 : a += 1, this.getDBData(a);
    },
    onShareAppMessage: function() {},
    getDBData: function(a) {
        var t = (e = this).data;
        1 == a && t.dataArr.splice(0, t.dataArr.length);
        var o = wx.cloud.database().collection("shareImage"), e = this;
        o.skip(10 * (a - 1)).limit(10).get({
            success: function(a) {
                console.log(a.data);
                for (var o = 0; o < a.data.length; o++) {
                    var n = a.data[o];
                    t.dataArr.push(n);
                }
                e.setData({
                    dataArr: t.dataArr
                }), a.data.length < 10 && 1 != sum && a.data.length < 10 && (sum -= 1), 1 == sum && wx.stopPullDownRefresh();
            }
        });
    },
    buttonClicked: function(a) {
        var t = a.detail.index;
        console.log(a), 0 == t ? wx.navigateTo({
            url: "/pages/about/about"
        }) : wx.chooseImage({
            count: 1,
            success: function(a) {
                var t = a.tempFilePaths[0];
                wx.navigateTo({
                    url: "/pages/sharePhoto/sharePhoto?imageUrl=" + t
                });
            }
        });
    },
    toDetail: function(a) {
        var t = [ a.currentTarget.id ];
        wx.previewImage({
            urls: t
        });
    }
});